#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

pid=$(pidof -o %PPID /usr/bin/ruijieclient)

case "$1" in
  start)
    if [ "${LOCALE%_*}x" = "zhx" ]; then
	stat_busy "正在启动 锐捷认证Linux客户端"
    else
	stat_busy "Starting Ruijieclient"
    fi
    [ -z "$pid" ] && /usr/bin/mystar >/dev/null 2>&1 &
    sleep 1
    if [ $? -gt 0 ]; then
      stat_fail
    else
      add_daemon ruijieclient
      stat_done
    fi
    ;;
  stop)
    if [ "${LOCALE%_*}x" = "zhx" ]; then
	stat_busy "正在关闭 锐捷认证Linux客户端"
    else
	stat_busy "Stopping Ruijieclient"
    fi
    [ ! -z "$pid" ]  && kill -9 $pid >/dev/null 2>&1
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon ruijieclient
      stat_done
    fi
    ;;
  restart)
    $0 stop
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"  
esac

exit 0
